cmake_minimum_required(VERSION 3.19)
project(classroom-computer LANGUAGES CXX)
set(PROJECT_VERSION "1.2.4")
string(REPLACE "." "," PROJECT_VERSION_NUMBER "${PROJECT_VERSION},0")
find_package(Qt6 6.10 REQUIRED COMPONENTS Core Gui Widgets Svg)
qt_standard_project_setup()
qt_add_resources(PROJECT_RESOURCES "ResourceFile.qrc")
set(PROJECT_SOURCES
	MANUAL_FINALIZATION
	${PROJECT_RESOURCES}
	main.cpp
	random-students.cpp
	random-students.h
	countdown.cpp
	countdown.h
	classroomcomputersettings.cpp
	classroomcomputersettings.h
	classroomcomputersettings.ui
	platforms.h
	global.h
	speaker.h
	applauncher.h
	applauncher.cpp
	borderprogresslabel.h
)
if(WIN32)
	configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
	qt_add_executable(classroom-computer ${PROJECT_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
	target_link_libraries(classroom-computer PRIVATE ole32 propsys)
else()
	qt_add_executable(classroom-computer ${PROJECT_SOURCES})
endif()
target_compile_definitions(classroom-computer PRIVATE PROJECT_VERSION="${PROJECT_VERSION}")
set_target_properties(classroom-computer PROPERTIES
	WIN32_EXECUTABLE ON
	MACOSX_BUNDLE ON
)
target_link_libraries(classroom-computer PRIVATE
	Qt6::Core
	Qt6::Gui
	Qt6::Widgets
	Qt6::Svg
)
target_include_directories(classroom-computer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
set(COMMON_PCH_HEADERS
	<cmath>
	<sstream>
	<QFileDialog>
	<QDateTime>
	<QMainWindow>
	<QApplication>
	<QParallelAnimationGroup>
	<QGraphicsDropShadowEffect>
	<QFontDatabase>
	<QPainter>
	<QGuiApplication>
	<QProcess>
	<QCloseEvent>
	<QTimer>
	<QDir>
	<QScreen>
	<QTextCharFormat>
	<QPropertyAnimation>
	<QThread>
	<QFile>
	<QMessageBox>
	<QRandomGenerator>
	<QFileSystemWatcher>
	<QSettings>
	<QTextStream>
	<QInputDialog>
	<QDateTime>
	<QListWidgetItem>
	<QSharedMemory>
	<QRect>
	<QWidget>
	<QFileInfoList>
	<QDataStream>
	<QLabel>
	<QScrollArea>
	<QScroller>
	<QScrollBar>
	<QObject>
	<QString>
	<QMutex>
	<QPushButton>
	<QGridLayout>
	<QJsonArray>
	<QJsonObject>
	<QDesktopServices>
	<QDialog>
	<QVBoxLayout>
	<QLabel>
	<QPixmap>
	<QFileIconProvider>
	<QScrollArea>
	<QMouseEvent>
	<QSvgRenderer>
	<QVector>
	<QStandardPaths>
	<QSpinBox>
	<QStringList>
)
if(WIN32)
	target_precompile_headers(classroom-computer PRIVATE
		${COMMON_PCH_HEADERS}
		<windows.h>
		<TlHelp32.h>
		<Psapi.h>
		<shlobj.h>
		<commoncontrols.h>
		<tchar.h>
		<sapi.h>
		<shellapi.h>
		<mmdeviceapi.h>
		<audiopolicy.h>
	)
else()
	target_precompile_headers(classroom-computer PRIVATE ${COMMON_PCH_HEADERS})
endif()
include(GNUInstallDirs)
install(TARGETS classroom-computer
	BUNDLE DESTINATION .
	LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
	RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
qt_finalize_executable(classroom-computer)
qt_generate_deploy_app_script(
	TARGET classroom-computer
	OUTPUT_SCRIPT deploy_script
	NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
